﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace VoxelBlock.PackMod
{
    public sealed class VoxelSurfaceData
    {
        public VoxelSurfaceData(int x, int y, int w, int h, int z, Color32[] colors)
        {
            this.z = z;
            this.x = x;
            this.y = y;
            this.w = w;
            this.h = h;
            this.colors = colors;
        }

        public Color32[] colors;
        public int index;
        public int x;
        public int y;
        public int z;
        readonly public int w;
        readonly public int h;


        public VoxelSurfaceData Copy()
        {
            return new VoxelSurfaceData(this.x, this.y, this.w, this.h, this.z, this.colors);
        }


        public override bool Equals(object obj)
        {

            if (obj is VoxelSurfaceData)
            {
                VoxelSurfaceData data = (VoxelSurfaceData)obj;
                if (data.x == this.x
                    && data.y == this.y
                    && data.z == this.z
                    && data.w == this.w
                    && data.h == this.h
                    && data.index == this.index
                    && data.colors.Length == this.colors.Length
                    )
                {
                    for (int i = 0; i < data.colors.Length; i++)
                    {
                        if (data.colors[i].Equals (this.colors[i]) )
                        {

                        }
                        else
                        {
                            return false;
                        }
                    }
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                return false;
            }
            //return base.Equals(obj);
        }
    }
}